POV-Ray : Newsgroups : povray.text.scene-files : Bicubic Patch Macro (Macro Code) : Bicubic Patch Macro (Macro Code) Server Time
3 Jul 2024 00:54:21 EDT (-0400)
  Bicubic Patch Macro (Macro Code)  
From: Dave Dunn
Date: 7 Feb 2002 17:51:53
Message: <3C63056A.1D933065@aol.com>
/*Here is a macro that emulates a wireframe modeler for a single bicubic
patch. This file is only the macro and should be saved as "patcher.mcr"
in order for the next scene file to render. The demo will be of a flat
sixteen point patch. changing the control points in the array will allow
you to model the bicubic patch interactively. This may come in handy for
anyone wanting to do a leaf, a flower petal, or a sheet of paper.  */

//Square Patch Array DO NOT DELETE! Copy to Scene.
#declare Points = array [16]
{
//Bottom Row
<-7.5,-7.5,0>, //0-2 Blue Corner Lower Left
<-2.5,-7.5,0>, //3-5 Yellow Lower Mid-Left
<2.5,-7.5,0>,  //6-8 Yellow Lower Mid-Right
<7.5,-7.5,0>, //9-11 Blue Corner Lower Right
//Second Row
<-7.5,-2.5,0>,  // 12-14 Yellow Left Lower Mid
<-2.5,-2.5,0>, //15-17 Green Center LL
<2.5,-2.5,0>,  //18-20 Green Center LR
<7.5,-2.5,0>,  //21-23 Yellow Right Lower Mid
//Third Row
<-7.5,2.5,0>, //24-26 Yellow Left Upper Mid
<-2.5,2.5,0>, //27-29 Green Center UL
<2.5,2.5,0>,  //30-32 Green Center UR
<7.5,2.5,0>,  //33-35 Yellow Right Upper Mid
//Top Row
<-7.5,7.5,0>, //36-38 Blue corner Upper Left
<-2.5,7.5,0>, //39-41 Yellow Upper Mid-Left
<2.5,7.5,0>, //42-44 Yellow Upper Mid-Right
<7.5,7.5,0> //45-47 Blue Corner Upper Right
}

#macro Patcher(Patch,Vertex,Wire,Color,XRay)
union {
#if (Patch = 1)
bicubic_patch {
type 1
flatness 0.01
u_steps 3
v_steps 3
Points[0]Points[1]Points[2]Points[3]
Points[4]Points[5]Points[6]Points[7]
Points[8]Points[9]Points[10]Points[11]
Points[12]Points[13]Points[14]Points[15]
pigment {Color #if(XRay=1) filter .6 #end}}
#end

#if(Vertex=1)
union {
sphere {Points[0],.2 pigment {Blue}}
sphere {Points[1],.2}
sphere {Points[2],.2}
sphere {Points[3],.2 pigment {Blue}}
sphere {Points[4],.2}
sphere {Points[5],.2 pigment {Green}}
sphere {Points[6],.2  pigment {Green}}
sphere {Points[7],.2}
sphere {Points[8],.2}
sphere {Points[9],.2 pigment {Green}}
sphere {Points[10],.2 pigment {Green}}
sphere {Points[11],.2}
sphere {Points[12],.2  pigment {Blue}}
sphere {Points[13],.2}
sphere {Points[14],.2}
sphere {Points[15],.2  pigment {Blue}}
pigment {Yellow} no_shadow} #end

#if(Wire=1)
union {
cylinder {Points[0],Points[1],.1}
cylinder {Points[1],Points[2],.1}
cylinder {Points[2],Points[3],.1}
cylinder {Points[4],Points[5],.1}
cylinder {Points[5],Points[6],.1}
cylinder {Points[6],Points[7],.1}
cylinder {Points[8],Points[9],.1}
cylinder {Points[9],Points[10],.1}
cylinder {Points[10],Points[11],.1}
cylinder {Points[12],Points[13],.1}
cylinder {Points[13],Points[14],.1}
cylinder {Points[14],Points[15],.1}
cylinder {Points[0],Points[4],.1}
cylinder {Points[4],Points[8],.1}
cylinder {Points[8],Points[12],.1}
cylinder {Points[1],Points[5],.1}
cylinder {Points[5],Points[9],.1}
cylinder {Points[9],Points[13],.1}
cylinder {Points[2],Points[6],.1}
cylinder {Points[6],Points[10],.1}
cylinder {Points[10],Points[14],.1}
cylinder {Points[3],Points[7],.1}
cylinder {Points[7],Points[11],.1}
cylinder {Points[11],Points[15],.1}
pigment {Red} no_shadow}
#end } #end


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.